package com.ruicar.afs.cloud.account.common.controller;

import com.ruicar.afs.cloud.account.common.entity.VoucherBusinessConfiguration;
import com.ruicar.afs.cloud.account.common.service.VoucherBusinessConfigurationService;
import com.ruicar.afs.cloud.account.vo.VoucherAtomVo;
import com.ruicar.afs.cloud.common.core.log.annotation.SysLog;
import com.ruicar.afs.cloud.common.core.query.QueryCondition;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author infinity
 * @version 1.0
 * @date 2020/7/12 15:34
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/voucherBusinessConfiguration")
@Api(value = "voucherBusinessConfiguration", description = "凭证事件配置信息")
public class VoucherBusinessConfigurationController {
private final VoucherBusinessConfigurationService voucherBusinessConfigurationService;

    @PostMapping("/addVoucherBusiness")
    @ApiOperation(value = "添加业务事件")
    @SysLog(value = "添加业务事件")
    public IResponse<Boolean> addVoucherBusiness(@RequestBody @Validated VoucherBusinessConfiguration voucherBusinessConfiguration){
        return IResponse.success(voucherBusinessConfigurationService.addVoucherBusiness(voucherBusinessConfiguration));
    }

    @DeleteMapping("/delVoucherBusiness/{atomId}")
    @ApiOperation(value = "删除业务事件")
    @SysLog(value = "删除业务事件")
    public IResponse<Boolean> delVoucherBusiness(@PathVariable String atomId){
        return IResponse.success(voucherBusinessConfigurationService.delVoucherBusiness(atomId));
    }

    @PostMapping("/modifyVoucherBusiness")
    @ApiOperation(value = "编辑业务事件")
    @SysLog(value = "编辑业务事件")
    public IResponse<Boolean> modifyVoucherBusiness(@RequestBody @Validated VoucherBusinessConfiguration voucherBusinessConfiguration){
        return IResponse.success(voucherBusinessConfigurationService.modifyVoucherBusiness(voucherBusinessConfiguration));
    }

    @PostMapping("/list")
    @ApiOperation(value = "查询业务事件")
    @SysLog(value = "查询业务事件")
    public IResponse list(@RequestBody QueryCondition<VoucherBusinessConfiguration> queryCondition){
        return voucherBusinessConfigurationService.query(queryCondition);
    }
    @PostMapping("/queryBusinessList")
    @ApiOperation(value = "查询业务事件")
    @SysLog(value = "查询业务事件")
    public IResponse queryBusinessList(@RequestBody VoucherBusinessConfiguration queryCondition){
        return voucherBusinessConfigurationService.queryBusinessList(queryCondition);
    }
    @PostMapping("/listBusinessChild")
    @ApiOperation(value = "查询业务子事件")
    @SysLog(value = "查询业务事件")
    public IResponse queryBusinessChildList(@RequestBody VoucherBusinessConfiguration queryCondition){
        return voucherBusinessConfigurationService.queryListChild(queryCondition);
    }
}


